using System;
using System.Collections.Generic;
using System.Text;

using System.IO;

namespace PotonCapture
{
    public class MakePath
    {
        private string _folder;

        public string Folder
        {
            get { return _folder; }
            set { _folder = value; }
        }

        private int _fileNumber = 1;

        public int FileNumber
        {
            get { return _fileNumber; }
            set { _fileNumber = value; }
        }

        private string _baseName = "image";

        public string BaseName
        {
            get { return _baseName; }
            set { _baseName = value; }
        }

        private string _fileExt;

        public string FileExt
        {
            get { return _fileExt; }
            set { _fileExt = value; }
        }
	

        public MakePath()
        {
            _folder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        }

        public void CreateFolder()
        {
            if (!Directory.Exists(_folder))
            {
                Directory.CreateDirectory(_folder);
            }
        }

        public string GetNextFilePath()
        {
            string path = null;
            for (; _fileNumber <= 9999; _fileNumber++)
            {
                string fileName = String.Format("{0}{1:0000}", _baseName, _fileNumber);
                fileName += "." + _fileExt;
                path = Path.Combine(_folder, fileName);
                if (!File.Exists(path))
                {
                    break;
                }
            }
            if (path == null)
            {
                System.Diagnostics.Debug.Print("capture path create error");
                return null;
            }
            System.Diagnostics.Debug.Print("capture path {0}", path);
            return path;
        }

    }
}
